package dao.mysql;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import dao.mysql.DBHelper;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

public class UserDAO {
    //判断登录是否成功
    public  int validateLogin(String string,String string2) {

        DBHelper connectNow = new DBHelper();
        Connection connectDB = connectNow.getConnection();

        String validateLogin = "SELECT count(1) FROM account WHERE userid = "+string + "AND password = "+string2;

        try {
            Statement statement = connectDB.createStatement();
            ResultSet queryResult = statement.executeQuery(validateLogin);

            while(queryResult.next()) {
                if(queryResult.getInt(1)==1) {
                    return 1;
                }else {
                    return 0;
                }
            }
        }catch(Exception e) {
            e.printStackTrace();
            e.getCause();
        }
        return 0;
    }
}
